package stardust.product.platform.webc.support;


import java.io.FileInputStream;
import java.net.URL;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;


public class FileUploadJApplet extends javax.swing.JApplet
{

  public void init()
  {
    try
    {
      java.awt.EventQueue.invokeAndWait(new Runnable()
      {
        public void run()
        {
          initComponents();
        }
      });
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
  }

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jButton1 = new javax.swing.JButton();

		setName("pnlMain");

		jButton1.setText("\u9009\u62e9\u6587\u4ef6...");
		jButton1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 105,
				Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 53,
				Short.MAX_VALUE));
	}// </editor-fold>
	//GEN-END:initComponents
  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
  {
    try
    {
      JOptionPane.showMessageDialog(this, "FDSFDSFDS");
      JFileChooser fileChooser = new JFileChooser();
      this.jButton1.setText(String.valueOf(fileChooser.showOpenDialog(this)));
      JOptionPane.showMessageDialog(this, fileChooser.getSelectedFile());
      HTTPSupport.post(new URL("http://localhost:8080/webctest/upload"), new FileInputStream(fileChooser.getSelectedFile()));
    }
    catch (Throwable e)
    {
      this.jButton1.setText(e.toString());
      JOptionPane.showMessageDialog(this, e.toString());
    }
  }
	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JButton jButton1;
	// End of variables declaration//GEN-END:variables
   
}